<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>学生信息添加</title>
    <link rel="stylesheet" href="${basePath}/plugins/kitadmin/css/theme/default.css" id="theme">
    <link rel="stylesheet" href="${basePath}/plugins/kitadmin/css/kitadmin.css" id="kitadmin">
    <link rel="stylesheet" href="${basePath}/css/doc.css">
    <link rel="stylesheet" href="${basePath}/plugins/kitadmin/css/layui.css" id="layui">
</head>
<body>

<div class="kit-doc">
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">楼　栋：</label>
            <div class="layui-input-block">
                <input type="text" name="roomBuilding" placeholder="请输入楼栋" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">门牌号：</label>
            <div class="layui-input-block">
                <input type="text" name="roomNumber" placeholder="请输入门牌号" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备　注：</label>
            <div class="layui-input-block">
                <textarea name="roomRemark" placeholder="请输入备注" class="layui-textarea" lay-verify="" autocomplete="off"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="add">提交</button>
        </div>
    </form>

</div>

<script src="${basePath}/js/jquery.js"></script>
<script src="${basePath}/plugins/kitadmin/layui.js"></script>
<script>
    layui.use(['laydate', 'form'], function () {
        var form = layui.form;
        //监听提交，发送请求
        form.on('submit(add)', function (data) {
            // 执行POST 请求
            $.post("add", data.field, function (data) {
                // 根据返回状态码输出提示信息，200 表示成功，其他表示失败
                if (data.status === 200) {
                    // 弹窗确认下一步操作
                    layer.open({
                        title: data.message,
                        type: 0,
                        btn: ["继续添加", "关闭"],
                        area: ['200px', '160px'],
                        content: '是否继续添加？',
                        // 弹出层弹出后回调
                        success: function () {
                        },
                        // 点击第一个按钮的响应事件
                        btn1: function (index) {
                            // 关闭弹窗
                            layer.close(index);
                        },
                        // 点击第二个按钮的响应事件
                        btn2: function (index) {
                            // 关闭弹窗
                            layer.close(index);
                            // 先得到当前iframe层的索引
                            var index2 = parent.layer.getFrameIndex(window.name);
                            // 关闭当前弹窗
                            parent.layer.close(index2);
                        }
                    });
                    // layer.alert(data.message, {offset: 't', icon: 1}, function (index) {
                    //     layer.close(index);
                    //     var index2 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    //     parent.layer.close(index2);
                    // });
                }
                else {
                    layer.alert(data.message, {offset: 't', icon: 2});
                }
            });
            return false;
        });
    });

</script>


</body>
</html>